<template>
  <div class="top-data">
    <div class="top-data-1">
      <p class="top-data-pn">浏览人数</p>
      <span class="top-data-n">49815</span>
    </div>
    <div class="top-data-1">
      <p class="top-data-pn">注册人数</p>
      <span class="top-data-n">32149</span>
    </div>
    <div class="top-data-1">
      <p class="top-data-pn">下单人数</p>
      <span class="top-data-n">2564</span>
    </div>
    <div class="top-data-1">
      <p class="top-data-pn">关注人数</p>
      <span class="top-data-n">33990</span>
    </div>
    <div class="top-data-1">
      <p class="top-data-pn">点赞人数</p>
      <span class="top-data-n">29965</span>
    </div>
    <div class="top-data-1">
      <p class="top-data-pn">浏览人数</p>
      <span class="top-data-n">49815</span>
    </div>
  </div>
  <div class="area-data">
    <p class="area-data-1">成交排行</p>
    <div style="display: flex; margin-top: 10px">
      <p class="area-data-2">地区</p>
      <el-input v-model="input1" placeholder="省" class="area-data-input" />
      <el-input v-model="input2" placeholder="市" class="area-data-input" />
      <el-input v-model="input3" placeholder="区" class="area-data-input" />
      <p class="area-data-3">时间</p>
      <el-input
        v-model="input4"
        placeholder="请输入内容"
        class="area-data-input"
      />
      <el-input
        v-model="input5"
        placeholder="请输入内容"
        class="area-data-input"
      />
      <el-input
        v-model="input6"
        placeholder="请输入内容"
        class="area-data-input"
      />
      <el-button class="area-data-btn1">重置</el-button>
      <el-button type="warning" plain class="area-data-btn2">确定</el-button>
    </div>
  </div>
  <div class="data">
    <el-table :data="tableData" stripe style="width: 100%">
      <el-table-column prop="goodsId" label="排名" width="160" />
      <el-table-column prop="usename" label="用户名" width="160" />
      <el-table-column prop="Address" label="地区" width="350" />
      <el-table-column prop="counts" label="数量" width="160" />
      <el-table-column prop="downMoney" label="成交金额(万元)" width="180" />
      <el-table-column prop="date" label="下单时间" width="240" />
    </el-table>
  </div>
  <!-- 分页 -->
  <div class="page">
    <!-- <el-pagination
      background
      layout="prev, pager, next"
      :total="total"
      :page-size="size"
      @next-click="next"
      @prev-click="prev"
      @current-change="current"
    ></el-pagination> -->
    <el-pagination
      background
      layout="prev, pager, next"
      :total="1000"
      :page-size="size"
      @next-click="next"
      @prev-click="prev"
      @current-change="current"
    >
    </el-pagination>
  </div>
</template>

<script>
import { ref, onMounted } from "vue";
import customerData from "../../../mock/customerData";

export default {
  setup() {
    const input1 = "";
    const input2 = "";
    const input3 = "";
    const tableData = ref([]);
    const size = ref(9);
    const page = ref(1);
    const total = ref();
    onMounted(async () => {
      const res = await customerData.getData({
        page: page.value,
        size: size.value,
      });
      if (res.status === 0) {
        tableData.value = [...res.result];
        total.value = res.count;
      }
    });
    // 分页
    const current = async (val) => {
      page.value = val;
      const res = await customerData.getData({
        page: page.value,
        size: size.value,
      });
      if (res.status === 0) {
        tableData.value = [...res.result];
        total.value = res.count;
      }
    };
    const next = async (val) => {
      page.value = val;
      const res = await customerData.getData({
        page: page.value,
        size: size.value,
      });
      if (res.status === 0) {
        tableData.value = [...res.result];
        total.value = res.count;
      }
    };
    const prev = async (val) => {
      page.value = val;

      const res = await customerData.getData({
        page: page.value,
        size: size.value,
      });
      if (res.status === 0) {
        tableData.value = [...res.result];
        total.value = res.count;
      }
    };

    return {
      input1,
      input2,
      input3,
      current,
      next,
      prev,
      tableData,
    };
  },
};
</script>

<style lang="less" scoped>
.top-data {
  width: 100%;
  height: 80px;
  background-color: #fff;
  display: flex;
  margin-top: 0px;
}
.top-data-1 {
  // 游览人数的外框
  width: 200px;
  height: 100%;
  margin-right: 20px;
}
.top-data-pn {
  margin-top: 20px;
  font-size: 14px;
  margin-left: 20px;
}
.top-data-n {
  font-size: 30px;
  display: block;
  margin-top: 8px;
  margin-left: 20px;
}
.area-data {
  width: 100%;
  height: 65px;
  // background-color: yellow;
  margin-top: 8px;
}
// 成交排行
.area-data-1 {
  font-size: 18px;
}
.area-data-2 {
  font-size: 16px;
  margin-top: 5px;
}
.area-data-3 {
  font-size: 16px;
  margin-top: 5px;
}
.area-data-input {
  width: 120px;
  height: 30px;
  margin: 0 15px;
}
.area-data-btn1 {
  width: 100px;
  height: 20px;
  margin-top: 5px;
}
.area-data-btn2 {
  width: 100px;
  height: 20px;
  margin-top: 5px;
}

.data {
  width: 100%;
}
.page {
  width: 81.5%;
  height: 20px;
  // background-color: yellow;
  position: fixed;
  right: -25%;
  bottom: 20px;
}
</style>
